/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package minesweeper.util;

import minesweeper.components.Board;

/**
 *
 * @author Cj
 */
public class CharArrayBuilder {
    
    //Uninstanciable
    private CharArrayBuilder(){}
    
    public static char[][] generateCharArray(Board board){
        char[][] storage = new char[board.getSectorWidth()][board.getSectorHeight()];
        
        for(int i = 0; i < storage.length; ++i){
            for(int j = 0; j < storage[i].length; ++j){
                if(board.revealedAtCoords(i, j)){
                    if(board.bombAtCoords(i, j)){
                        storage[i][j] = 'B';
                    }else{
                        storage[i][j] =(char)board.numAtCoords(i, j);
                    }
                }else{
                    storage[i][j] = 'H';
                }
            }
        }
        
        return storage;
    }
    
    public static String charArrayToString(char[][] storage){
        String result = "";
        for(int y = 0; y < storage[0].length; ++y){
            for(int x = 0; x < storage.length; ++x){
                result += storage[y][x];
            }
            result += '\n';
        }
        return result;
    }
    
    
    
}
